<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>4.Vue监测数组改变的原理</title>
		<script type="text/javascript" src="../js/vue.js"></script>
	</head>
	<body>
		<div id="demo">
			<h1>人员信息</h1>
			<ul>
				<li>姓名：{{name}}</li>
				<li>年龄：{{age}}</li>
				<li>爱好：{{hobby}}</li>
			</ul>
			<button @click="changeName">改名</button>
			<button @click="changeAge">改年龄</button>
			<button @click="changeFirstHobby">改第1个爱好</button>
		</div>
	</body>

	<script type="text/javascript">
		Vue.config.productionTip = false
		
		const vm = new Vue({
			el:'#demo',
			data:{
				name:'王帅',
				age:18,
				hobby:['抽烟','喝酒','烫头'],
				a:{b:{c:{d:9}}}
			},
			methods:{
				changeName(){
					this.name = '托尼'
				},
				changeAge(){
					this.age = 20
				},
				changeFirstHobby(){
					this.hobby.splice(0,1,'学习')
				},
			}
		})
		console.log(vm)
	</script>
</html>